package com.ruoyi.park.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.park.domain.ClRecordArea;
import com.ruoyi.park.service.IClRecordAreaService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 清洁记录区域Controller
 *
 * @author cjie
 * @date 2021-09-16
 */
@Api(tags = " 清洁记录区域")
@RestController
@RequestMapping("/clRecordArea")
public class ClRecordAreaController extends BaseController {
    @Autowired
    private IClRecordAreaService clRecordAreaService;

    /**
     * 查询清洁记录区域列表
     */
    @ApiOperation(value="查询清洁记录区域列表", notes="查询清洁记录区域列表")
    @PreAuthorize(hasPermi = "park:clRecordArea:list")
    @GetMapping("/list")
    public TableDataInfo list(ClRecordArea clRecordArea) {
        startPage();
        List<ClRecordArea> list = clRecordAreaService.selectClRecordAreaList(clRecordArea);
        return getDataTable(list);
    }

    /**
     * 导出清洁记录区域列表
     */
    @ApiOperation(value="导出清洁记录区域列表", notes="导出清洁记录区域列表")
    @PreAuthorize(hasPermi = "park:clRecordArea:export")
    @Log(title = "清洁记录区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClRecordArea clRecordArea) throws IOException {
        List<ClRecordArea> list = clRecordAreaService.selectClRecordAreaList(clRecordArea);
        ExcelUtil<ClRecordArea> util = new ExcelUtil<ClRecordArea>(ClRecordArea.class);
        util.exportExcel(response, list, "清洁记录区域数据");
    }
    /**
     * 获取清洁记录区域详细信息
     */
    @ApiOperation(value="获取清洁记录区域详细信息", notes="获取清洁记录区域详细信息")
    @PreAuthorize(hasPermi = "park:clRecordArea:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(clRecordAreaService.selectClRecordAreaById(id));
    }

    /**
     * 新增清洁记录区域
     */
    @ApiOperation(value="新增清洁记录区域", notes="新增清洁记录区域")
    @PreAuthorize(hasPermi = "park:clRecordArea:add")
    @Log(title = "清洁记录区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClRecordArea clRecordArea) {
        return toAjax(clRecordAreaService.insertClRecordArea(clRecordArea));
    }

    /**
     * 修改清洁记录区域
     */
    @ApiOperation(value="修改清洁记录区域", notes="修改清洁记录区域")
    @PreAuthorize(hasPermi = "park:clRecordArea:edit")
    @Log(title = "清洁记录区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClRecordArea clRecordArea) {
        return toAjax(clRecordAreaService.updateClRecordArea(clRecordArea));
    }

    /**
     * 删除清洁记录区域
     */
    @ApiOperation(value="删除清洁记录区域", notes="删除清洁记录区域")
    @ApiImplicitParam(name = "ids", value = "清洁记录区域ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "park:clRecordArea:remove")
    @Log(title = "清洁记录区域", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(clRecordAreaService.deleteClRecordAreaByIds(ids));
    }
}
